<?php
include 'ControllerInterface.php';

abstract class AbstractController implements  ControllerInterface{
            protected $name;
            
            protected $session;
            protected $request;
            
            protected $model;
            protected $controller; 
            protected $view; 
            
            protected $parent; 
            
            
            
            public function __construct($request,$session=null){
                $this->session=$session;
                $this->request=$request;
                $this->controller=array();
                 $this->parent=null;
                  
            }
            
            
            public function getHttp(){
                  foreach($this->controller as $controller ){
                        $controller->createHttp();
                  }
                  
                  $this->createHttp(); 
            }
            
            public function getModel(){
                  foreach($this->controller as $controller ){
                        $controller->createModel();
                  }
                  
                   $this->createModel(); 
            }
            
            public function getView(){
                  $this->view[$this->name]=$this->createView();
                  foreach($this->controller as $controller ){
                        $this->view[$this->name][]=$controller->getView();
                  } 
                  
            }
            
            public function getParent(){
                  return $this->parrent;
            }
            
            
            public function setParent($controller){
                  $this->parent=$controller;
            }
            
            public function addController($controller){
                  $this->controller[]=$controller;
                  $controller->setParent($this);
            }
            
}

?>
